// pages/sigIn/sigIn.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    peopleNum: 0,
    arrList:'',
    topThree:'',
    afterPepole:'',
    first:'',
    second:'',
    third:''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.siginList()
  },

  siginList() {
    let _that = this
    wx.request({
      url: 'https://www.fastmock.site/mock/c8d5c34bf3ee845da580d0512be05fa9/shop/sigin',
      data: {},
      method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
      // header: {}, // 设置请求的 header
      success: function (res) {
        
        if (res.data.code == '000') {
          const arr=res.data.data.sort(_that.sortCount("count"))
          const three= arr.slice(0,3)//不包括3
          const people=arr.slice(3)//包括3
          for (const i in three) {
            var first1=three[0]
            var second1=three[1]
            var third1=three[2]
          }
          _that.setData({
            peopleNum: res.data.data.length,
            arrList:arr,
            topThree:three,
            afterPepole:people,
            first:first1,
            second:second1,
            third:third1
          }) 
        }
       
      },
      fail: function () {
        // fail
      },
      complete: function () {
        // complete
      }
    })
  },

  sortCount:function(count){
     return function (a, b) {
      var value1 = a[count];
      var value2 = b[count];
      return value2 - value1
     }
	},


  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },



  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})